/**
 *
 * User: Zhikang.Peng
 * Date: 2018/04/12 11:30
 */
package conversions

import (
	"gitee.com/thghh/jvmgo/instructions/base"
	"gitee.com/thghh/jvmgo/rtda"
)

// 将栈顶float型数值强制转换成int型数值并将结果压入栈顶
type F2I struct{ base.NoOperandsInstruction }

func (self *F2I) Execute(frame *rtda.Frame) {
	stack := frame.OperandStack()
	f := stack.PopFloat()
	i := int32(f)
	stack.PushInt(i)
}

// 将栈顶float型数值强制转换成long型数值并将结果压入栈顶
type F2L struct{ base.NoOperandsInstruction }

func (self *F2L) Execute(frame *rtda.Frame) {
	stack := frame.OperandStack()
	f := stack.PopFloat()
	l := int64(f)
	stack.PushLong(l)
}

// 将栈顶float型数值强制转换成double型数值并将结果压入栈顶
type F2D struct{ base.NoOperandsInstruction }

func (self *F2D) Execute(frame *rtda.Frame) {
	stack := frame.OperandStack()
	f := stack.PopFloat()
	d := float64(f)
	stack.PushDouble(d)
}
